windowSize=150;
yrms=[]; % moving RMS, takes RMS of each sample based on window size
yrms(length(newy2)-windowSize)=0;
for i=1:(length(newy2)-windowSize)
    yrms(i)=sqrt(mean(newy(i:i+windowSize).^2));
end
%%
avWinSz=500;
yrmsa=[]; % moving average of the RMS data
yrmsa(length(yrms)-avWinSz)=0;
for a=1:avWinSz
    yrmsa = yrmsa+1/avWinSz*yrms(a:(end-avWinSz+a-1));
end


figure;
plot(yrms);

figure;
plot(yrmsa);